import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GuildPartyConfig } from "../../../resource/GuildPartyConfig";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GuildPartyRewardItem } from "./GuildPartyRewardItem";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ItemData } from "../../../resource/info/ItemData";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class GuildPartyRewardWindow
    
    export  class GuildPartyRewardWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._juItemArray = [];
            this._getItemArray = [];
            this.setSize(450, 450);
            this.titleHeight = 28;
            this.title = Language.getString(57624);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            var loc4=null;
            var loc5=null;
            var loc7=null;
            var loc9=null;
            super.createChildren();
            ObjCreate.createFlowerBg(17, 39, 415, 400, this);
            ObjCreate.createBg(35, 70, 380, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(35, 105, 380, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(35, 195, 380, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(35, 330, 380, 2, this, ImagesConst.SplitLine);
            var loc1=GuildPartyConfig.instance.partyConfigArray;
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                loc2 = loc1[loc3];
                (loc9 = ObjCreate.createGTextField("", 185 + loc3 * 90, 80, 100, 20, this, GlobalStyle.textFormat6)).autoSize = flash.text.TextFieldAutoSize.LEFT;
                loc9.text = loc2.costGold.toString();
                ObjCreate.createBitmap(ImagesConst.Yuanbao, loc9.x + 25, loc9.y, this);
                ++loc3;
            }
            this.createRewardItem(145, 115, 1, 1, 1.25, 1.5);
            this.createRewardItem(145, 145, 2, 1, 2.5, 5);
            this.createRewardItem(145, 175, 3, 1, 1.25, 1.5);
            this.createRewardItem(145, 205, 1, 1, 1.25, 1.5);
            this.createRewardItem(145, 235, 2, 2, 5, 10);
            this.createRewardItem(145, 265, 3, 1, 1.25, 1.5);
            ObjCreate.createGTextField(Language.getString(57264), 145, 295, 100, 20, this, GlobalStyle.textFormatPurple);
            var loc6=0;
            while (loc6 < 3) 
            {
                loc5 = ObjCreate.createBg(195 + loc6 * 80, 287, 38, 38, this, ImagesConst.PackItemBg);
                (loc4 = new BaseItem()).isDragAble = false;
                loc4.setSize(32, 32);
                if (loc6 == 2) 
                {
                    loc5.x = 205 + loc6 * 80;
                }
                loc4.x = loc5.x + 2;
                loc4.y = 289;
                this.addChild(loc4);
                this._juItemArray.push(loc4);
                ++loc6;
            }
            var loc8=0;
            while (loc8 < 9) 
            {
                ObjCreate.createBg(40 + loc8 * 42, 370, 38, 38, this, ImagesConst.PackItemBg);
                (loc7 = new BaseItem()).isDragAble = false;
                loc7.setSize(32, 32);
                loc7.x = 42 + loc8 * 42;
                loc7.y = 372;
                this.addChild(loc7);
                this._getItemArray.push(loc7);
                ++loc8;
            }
            this._descTxt = ObjCreate.createGTextField("", 0, 415, 410, 20, this, GlobalStyle.textFormatGreen);
            this._descTxt.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._descTxt.htmlText = "<a href=\'event: 0\'><u>" + Language.getString(57418) + "</u></a>";
            this._descTxt.addEventListener(flash.events.TextEvent.LINK, this.onDescTxtClickHandler);
            this.updateData();
            LoaderHelp.addResCallBack(ResFileConst.GuildPartyReward, this.onLoadedHandler);
            return;
        }

        /* internal  */onLoadedHandler(): void
        {
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardType0, 175, 45, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardType1, 260, 45, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardType2, 345, 45, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardLabel1, 30, 75, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardLabel2, 30, 110, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardLabel3, 30, 205, this);
            ObjCreate.createBitmap(ImagesConst.GuildPartyRewardLabel4, 30, 340, this);
            return;
        }

        /* internal  */createRewardItem(arg1: int, arg2: int, arg3: int, arg4: number, arg5: number, arg6: number): void
        {
            var loc1=null;
            (loc1 = new GuildPartyRewardItem()).x = arg1;
            loc1.y = arg2;
            loc1.updateData(arg3, arg4, arg5, arg6);
            this.addChild(loc1);
            return;
        }

        /* internal  */updateData(): void
        {
            var loc3=null;
            var loc5=null;
            var loc1=GameDefConfig.instance.getGuildPartyRewards(0);
            var loc2=GameDefConfig.instance.getGuildPartyRewards(1);
            var loc4=0;
            while (loc4 < loc1.length) 
            {
                loc3 = this._juItemArray[loc4];
                loc3.itemData = loc1[loc4] as ItemData;
                ++loc4;
            }
            var loc6=0;
            while (loc6 < loc2.length) 
            {
                (loc5 = this._getItemArray[loc6]).itemData = loc2[loc6] as ItemData;
                ++loc6;
            }
            return;
        }

        /* internal  */onDescTxtClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildPartyDescWindowOpen));
            return;
        }

        /* internal */ /* var */_descTxt: GTextFiled;

        /* internal */ /* var */_juItemArray: Array<any>;

        /* internal */ /* var */_getItemArray: Array<any>;
    }
